﻿/***********************************************************************************************
 * 
 * ProjectName: WMSSoft.Lib.Basic
 * 
 * Description: Static class for basic helper methods
 * 
 * Created:     21.07.2012
 * 
 * Author:      matthias wagler - matthias@WMSSoft.de
 * 
 * Copyright:   Copyright 2012 by WMSSoft.net
 * 
 * License:     GPLv3
 * 
 * History:     21.07.2012 - matthias wagler matthias@WMSSoft.net   -   Created
 * 
 **********************************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;

namespace WMSSoft.Lib.Basic
{
    /// <summary>
    /// Class contains basic helper methods
    /// </summary>
    public static class basic_helpers
    {
        /// <summary>
        /// Test object for numeric value
        /// </summary>
        /// <param name="Value">Value to Test</param>
        /// <returns>True if Value is a Numeric Value otherwise False</returns>
        public static bool isNumeric(Object Value)
        {
            try
            {
                int myint = Convert.ToInt32(Value);
                return true;
            }
            catch
            {
                return false;
            }
        }

        /// <summary>
        /// Test Object for Double Numeric value
        /// </summary>
        /// <param name="Value">Value to Test</param>
        /// <returns>True if Value is a Double Numeric Value otherwise False</returns>
        public static bool IsDoubleNumeric(Object Value)
        {
            try
            {
                double dValue = Convert.ToDouble(Value);
                return true;
            }
            catch
            {
                return false;
            }
        }

        /// <summary>
        /// Replace wrong Chars from an input string to get a string to output in an XML File
        /// </summary>
        /// <param name="Input">Input string on this replace wrong chars</param>
        /// <returns>String that can write to a XML File</returns>
        public static string ReplaceInvalidNameChars ( string Input )
        {
            try
            {
                string sTmpInput = Input;
                sTmpInput = sTmpInput.Replace(" ", "");
                sTmpInput = sTmpInput.Replace("*", "");
                sTmpInput = sTmpInput.Replace("-", "");
                sTmpInput = sTmpInput.Replace("+", "");
                sTmpInput = sTmpInput.Replace(",", "");
                sTmpInput = sTmpInput.Replace("~", "");
                sTmpInput = sTmpInput.Replace("´", "");
                sTmpInput = sTmpInput.Replace("`", "");
                sTmpInput = sTmpInput.Replace("?", "");
                sTmpInput = sTmpInput.Replace("ß", "");                
                sTmpInput = sTmpInput.Replace("=", "");
                sTmpInput = sTmpInput.Replace("}", "");
                sTmpInput = sTmpInput.Replace("]", "");
                sTmpInput = sTmpInput.Replace("[", "");
                sTmpInput = sTmpInput.Replace(")", "");
                sTmpInput = sTmpInput.Replace("(", "");
                sTmpInput = sTmpInput.Replace("{", "");
                sTmpInput = sTmpInput.Replace("/", "");
                sTmpInput = sTmpInput.Replace("&", "");
                sTmpInput = sTmpInput.Replace("%", "");
                sTmpInput = sTmpInput.Replace("$", "");
                sTmpInput = sTmpInput.Replace("§", "");
                sTmpInput = sTmpInput.Replace("!", "");

                return sTmpInput;

            }
            catch 
            {
                return "";
            }
        }
        
        
    }
}
